package vip.xiaonuo.smzq.modular.lifecycle.vo;



import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import vip.xiaonuo.smzq.modular.lifecycle.entity.KclWjglb;
import vip.xiaonuo.smzq.modular.lifecycle.entity.LifeCycleMineStore;
import vip.xiaonuo.smzq.modular.lifecycle.entity.LifeCycleMineralMea;
import vip.xiaonuo.smzq.modular.lifecycle.entity.LifeCyclePedigee;
import vip.xiaonuo.smzq.modular.lifecycle.util.FileUtils;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class QueryMineStoreVO extends LifeCycleMineStore {
    @ApiModelProperty(value="矿石类型")
    private String mineralType;

    @ApiModelProperty(value="文件列表")
    private List<KclWjglb> kclWjglbList;
    @ApiModelProperty(value="储量值")
    private Double storeVal;

    @ApiModelProperty(value="图谱节点列表")
    private List<LifeCyclePedigee> lifeCyclePedigeeList;
    @ApiModelProperty(value="矿石量列表")
    private List<LifeCycleMineralMea> lifeCycleMineralMeaList;

    @ApiModelProperty(value="矿区范围图片base64")
    private String mineAreaBase64;

    @ApiModelProperty(value="主矿产码")
    private Integer zkcm;

    @ApiModelProperty(value="审批状态")
    private String spzt;

    public void initMineAreaBase64(){
        if(StrUtil.isNotBlank(super.getMineralAreaPath())){
            if(FileUtil.exist(super.getMineralAreaPath())){
                this.setMineAreaBase64(FileUtils.getBase64ImgStr(super.getMineralAreaPath()));
            }
        }
    }

    /**
     * 初始化矿石类型
     */
    public void initMineralMea(Integer mineralType,Double tjdx,String kclb){
        List<LifeCycleMineralMea> lcmm = this.lifeCycleMineralMeaList.stream().filter(ele->
                        ObjectUtil.isNotEmpty(mineralType)?ObjectUtil.equals(ele.getMineralType(),mineralType):false
                        && ObjectUtil.isNotEmpty(tjdx)?ObjectUtil.equals(tjdx,ele.getTjdx()):false
                        && ObjectUtil.isNotEmpty(kclb)?StrUtil.equals(kclb,ele.getKclb()):true
        ).collect(Collectors.toList());
        this.setLifeCycleMineralMeaList(lcmm);
    }

    /**
     * 初始化族谱名称
     */
    public void initOtherAll(){
        for (LifeCyclePedigee lifeCyclePedigee:this.getLifeCyclePedigeeList()) {
//            设置族谱名称
            lifeCyclePedigee.setName(StrUtil.isBlank(lifeCyclePedigee.getName())?this.getReportName():lifeCyclePedigee.getName());

//            lifeCyclePedigee.setExporeType(this.getExporeType());

            lifeCyclePedigee.setZkcm(this.getZkcm());
            lifeCyclePedigee.setExporeType(ObjectUtil.isEmpty(lifeCyclePedigee.getExporeType())?this.getExporeType():lifeCyclePedigee.getExporeType());

        }
    }

    /**
     * 初始化族谱矿山为次矿山的族谱
     */
    public void initPedSec(){
        for (LifeCyclePedigee lifeCyclePedigee:getLifeCyclePedigeeList()) {
            lifeCyclePedigee.setMainMine(false);
        }
    }

}
